<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cashpoint_model extends CI_Model {

	function __construct() {
		parent::__construct();

		$this->load->library('LogSql');
	}

	/**
	 * 포인트 상품 리스트 가져오기
	 */
	function select_cash_to_point_list() {
		log_message('debug',"### Cashpoint_model::select_cash_to_point_list()");

		$query = $this->db->get('tb_cash_to_point') or $this->logsql->log_sql('error');
		$result = $query->result_array();
		
		$this->logsql->log_sql();
		$this->logsql->log_result($result);

		return $result;
	}

	/**
	 * 포인트 상품 업데이트
	 */
	function update_cash_to_point($cashpoint) {
		log_message('debug',"#### Cashpoint_model::update_cash_to_point($cashpoint)");

		$this->db->set('update_dt', 'now()', FALSE);
		$this->db->where('idx', $cashpoint['idx']);
		$this->db->update('tb_cash_to_point', $cashpoint) or $this->logsql->log_sql('error');
		
		$this->logsql->log_sql();
	}

	// 포인트 상품 등록
	function insert_cash_to_point($cashpoint) {
		log_message('debug',"#### Cashpoint_model::insert_cash_to_point($cashpoint)");

		$this->db->set('create_dt', 'now()', FALSE);
		$this->db->set('update_dt', 'now()', FALSE);
		$this->db->insert('tb_cash_to_point', $cashpoint) or $this->logsql->log_sql('error');
		
		$this->logsql->log_sql();
	}

	// 포인트 상품 삭제
	function delete_cash_to_point($idx) {
		log_message('debug',"#### Cashpoint_model::delete_cash_to_point($idx)");

		$this->db->delete('tb_cash_to_point', array('idx'=>$idx)) or $this->logsql->log_sql('error');
		
		$this->logsql->log_sql();
	}
}

/* End of file cashpoint_model.php */
/* Location: ./application/models/product/cashpoint_model.php */